const express = require('express');
const path = require('path');

const app = express();

console.log("__dirname:",__dirname);

// Set view engine to ejs
//app.set('view engine', 'ejs');

app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.set('views', path.join(__dirname, 'views'));

// Serve static files
app.use(express.static(path.join(__dirname, 'public')));

// Routes
app.get('/', (req, res) => {
  const data={
    title: 'My First EJS App',
    message: 'Hello, this is my first EJS app!',
    user: { name: 'Alice', age: 25 },
    items: [
      "1",
      "2",
    ]
  }
  for(var i=0;i<1000;i++){
    data.items.push("中国检验认证集团奢侈品鉴定中心是中检集团设立在中检北京公司的“国字头”第三方奢侈品鉴定机构，我们致力以独立于买卖各方的身份，为社会各界提供公证诚信的第三方奢侈品真伪鉴定与技术保障，有效遏制售假，净化购物环境，维护消费者权益，促进我国奢侈品市场的健康发展。");

  }
  res.render('index', data);
});

// Start server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server running on http://localhost:${PORT}`);
});